from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
'''
注册(前台)
登录(前后台)
前台商品查找 
前台地址：http://192.168.1.241/hdshop     
后台地址：http://192.168.1.241/hdshop/admin/（admin/hdxy2018）
'''

driver = webdriver.Chrome()
driver.get("http://192.168.1.241/hdshop/admin/")
driver.maximize_window()

driver.find_element(By.NAME,"username").send_keys("admin")
driver.find_element(By.NAME,"password").send_keys("hdxy2018")
driver.find_element(By.CLASS_NAME,"btn-a").click()
sleep(5)
# driver.switch_to.frame(1)
driver.switch_to.frame("menu-frame")
# driver.switch_to.frame("menu-frame")
# driver.switch_to.frame(driver.find_element_by_id("menu-frame"))
# driver.switch_to.parent_frame()
# driver.switch_to.default_content()
# driver.switch_to.frame("main-frame")
driver.find_element(By.XPATH,'/html/body/div[2]/div[1]/ul/li[1]')\
.find_element(By.XPATH,'//*[@id="menu-ul"]/li[1]/ul/li[1]/a').click()
# driver.find_element_by_xpath('//*[@id="menu-ul"]/li[1]/text()').click()

sleep(15)
driver.quit()


